<template>
	<view class="cardpin-bg">
		<!-- <view class="cardpin-header">
			<text class="cardpin-title">卡密兑换</text>
		</view> -->
		<view class="cardpin-card">
			<view class="input-wrapper">
				<image class="input-icon" src="@/static/xinjiang/bx-key.png" mode="aspectFit" />
				<input
					class="cardpin-input"
					v-model="cardPin"
					placeholder="请输入卡密"
					maxlength="32"
					confirm-type="done"
				/>
			</view>
			<view class="cardpin-btn-group">
				<button class="cardpin-btn redeem" @click="onRedeem">充值钻石</button>
				<button class="cardpin-btn buy" @click="onBuy">购买充钻卡密</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {CardSecretExchange} from '@/common/api.js'

	export default {
		data() {
			return {
				cardPin: ''
			};
		},
		methods: {
			onRedeem() {
				if (!this.cardPin) {
					uni.showToast({ title: '请输入卡密', icon: 'none' });
					return;
				}
				uni.showLoading({
					title: '正在兑换中'
				})
				CardSecretExchange({ code: this.cardPin }).then(({ code, msg }) => {
					uni.showToast({
						title: msg,
						icon: 'none'
					})
					if (code === 200) {
						this.updateUserinfo()
					}
				})
			},
			onBuy() {
				uni.showToast({ title: '敬请期待', icon: 'none' });
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cardpin-bg {
		min-height: 100vh;
		// background: linear-gradient(135deg, #0862EC 0%, #4faaff 100%);
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 120rpx;
	}
	.cardpin-header {
		width: 100vw;
		display: flex;
		justify-content: center;
		margin-bottom: 40rpx;
	}
	.cardpin-title {
		color: #fff;
		font-size: 48rpx;
		font-weight: bold;
		letter-spacing: 2rpx;
		text-shadow: 0 4rpx 16rpx rgba(8,98,236,0.18);
	}
	.cardpin-card {
		width: 86vw;
		max-width: 600rpx;
		background: #fff;
		border-radius: 24rpx;
		box-shadow: 0 8rpx 32rpx rgba(8,98,236,0.10);
		padding: 56rpx 36rpx 48rpx 36rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.input-wrapper {
		width: 100%;
		display: flex;
		align-items: center;
		background: #f7faff;
		border-radius: 16rpx;
		box-shadow: 0 2rpx 8rpx rgba(8,98,236,0.04);
		margin-bottom: 48rpx;
		border: 2rpx solid #e3eefd;
		padding: 0 18rpx;
	}
	.input-icon {
		width: 40rpx;
		height: 40rpx;
		margin-right: 12rpx;
	}
	.cardpin-input {
		flex: 1;
		height: 88rpx;
		border: none;
		background: transparent;
		font-size: 28rpx;
		color: #222;
		outline: none;
	}
	.cardpin-btn-group {
		width: 100%;
		display: flex;
		flex-direction: column;
		gap: 28rpx;
	}
	.cardpin-btn {
		width: 100%;
		height: 88rpx;
		border-radius: 16rpx;
		font-size: 32rpx;
		font-weight: bold;
		letter-spacing: 2rpx;
		margin: 0;
		box-shadow: 0 2rpx 8rpx rgba(8,98,236,0.08);
		transition: background 0.2s;
	}
	.cardpin-btn.redeem {
		background: linear-gradient(90deg, #0862EC 0%, #4faaff 100%);
		color: #fff;
		border: none;
	}
	.cardpin-btn.buy {
		background: #fff;
		color: #0862EC;
		border: 2rpx solid #0862EC;
	}
	.cardpin-btn:active {
		opacity: 0.85;
	}
</style>
